<?php


class ThunderService
{
	
	public function __construct() 
	{
			
	}

	public function getFileListXML($dateQSStr,$dateZZStr) 
	{

	   
	}
	
	/**
	 * Utility function to throw an exception if an error occurs 
	 * while running a mysql command.
	 */
	private function throwExceptionOnError($link = null) {
		throw new Exception('MySQL Error - ');
	}
}

	function outputDirFile($dir)
    {
	    if ($handle = opendir($dir)) 
	    {
	        while (false !== ($file = readdir($handle))) 
	        {
	              if ($file != "." && $file != "..") 
	              {           
	                	$child_dir = $dir."/".$file;
	                	if(is_dir($child_dir))
	                    {
	                     	$filename = mb_convert_encoding($file,   "UTF-8","GB2312");
	                       	echo '<dir name="'.$filename.'" >';
	                       	outputDirFile($child_dir);
	                       	echo "</dir>";
	                     }
	               		else
	               		{
	                     	$filesize = sprintf("%01.2f", filesize($child_dir)/1024) ."kb";
	                     	$fileatime = date("Y-m-d H:i:s", fileatime($child_dir));
	                     	$filemtime = date("Y-m-d H:i:s", filemtime($child_dir));
	                     	$filename = mb_convert_encoding($file,   "UTF-8","GB2312");
	                     	$filedir = mb_convert_encoding($dir,   "UTF-8","GB2312");
	                     	
	               			echo '<file checked="0" name="'.$filename.'" url="'.$filedir.'" size="'.$filesize.'" atime="'.$fileatime.'" ftime="'.$filemtime.'" tag=""/>';
	               		} 
	               }
	       	}
	       closedir($handle);
	    }
	 }
 	
 	$fileDir = $_REQUEST["dir"];
 	//$fileDir = "F:\\software";
 	
 	
 	header("Content-type: text/xml"); 
 	echo '<?xml version="1.0" encoding="UTF-8" ?>';
 	
 	echo "<filelist>";
		$fileDirname = mb_convert_encoding($fileDir,   "UTF-8","GB2312");
		echo '<dir name="'.$fileDirname.'" hasChildren="true">';
	   		outputDirFile($fileDir);	 
   		echo "</dir>";
 	echo "</filelist>";
?>
